package com.future.cglib.v3;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;

/**
 * Description:
 *
 * @author weiruibai.vendor
 * Date: 2021/9/8 15:21
 */
public class BookServiceFactory extends AbstractCglibFactory<BookServiceBean> {

    private MethodInterceptor interceptor;

    public BookServiceFactory(MethodInterceptor interceptor) {
        this.interceptor = interceptor;
    }

    @Override
    public BookServiceBean getProxyInstance() {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(BookServiceBean.class);
        enhancer.setCallback(interceptor);
        //   生成代理实例
        return (BookServiceBean) enhancer.create();
    }
}
